/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
#include <stdio.h>

struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
};

void reverse(struct TreeNode * root) {
    if(root == NULL) {
        return;
    }
    struct TreeNode * temp;
    temp = root->left;
    root->left = root->right;
    root->right = temp;
    reverse(root->left);
    reverse(root->right);
}

struct TreeNode* invertTree(struct TreeNode* root){
    reverse(root);
    return root;
}